package com.digital.herbarium.Controller;

import com.digital.herbarium.annotation.CheckToken;
import com.digital.herbarium.Entity.ResponseResult;
import com.digital.herbarium.Entity.Role;
import com.digital.herbarium.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/role")
public class RoleController {


    @Autowired
    RoleService roleService;


    @GetMapping("getRoleInfo")
    @CheckToken()
    public ResponseResult getRoleInfo(Role role){
        return ResponseResult.SUCCESS().setData( roleService.getRoleInfo(role));
    }



    @PostMapping("addRole")
    @CheckToken()
    public  ResponseResult addRole(Role role){
        roleService.addRole(role);
        return ResponseResult.SUCCESS().setData("添加成功");
    }

    @PostMapping("editRole")
    @CheckToken()
    public ResponseResult editRole(Role role){
        roleService.editRole(role);
        return  ResponseResult.SUCCESS().setData("更新成功");
    }

    @GetMapping("delRole")
    @CheckToken()
    public ResponseResult delRole(String id){
        roleService.delRole(id);
        return  ResponseResult.SUCCESS().setData("删除成功");
    }
}
